#include <stdio.h>
#include <stdlib.h>

typedef int DataType;
struct LinearList {
        int Maxnum;
        DataType *element; // 动态存储
        int len;
};
typedef struct LinearList *List;

List CreateNewList(int m)
{
        // 动态分配一个struct LinearList给list.
        List list = (List)malloc(sizeof(struct LinearList));
        // 为list中的成员变量element动态分配一块长度为m存储空间.
        list->element = (DataType *)calloc(m, sizeof(DataType));
        list->len = m;
        list->Maxnum = 100;
        return list;
}


void print_list(List list)
{
        for (int i = 0; i < list->len; i++) {
                printf("%d ", list->element[i]);
        }
        printf("\n");
}

void print_arr(int *a, int len)
{
        for (int i = 0; i < len; i++)
                printf("%d ", a[i]);
        printf("\n");
}

void fuzhi(int *ret, int *a, int *ret_len, int *a_len)
{
        /*
        printf("2a_len: %d\n", *a_len);
        printf("2ret_len: %d\n", *ret_len);
        */
        for (int i = 0; i < *a_len; i++)
                ret[i] = a[i];
        *ret_len = *a_len;
}

int *FindMostSonList(List L)
{
        int *ret = (int *)calloc(L->len, sizeof(int));
        int *a = (int *)calloc(L->len, sizeof(int));
        int alen, retlen;
        int *a_len, *ret_len;
        a_len = &alen; ret_len = &retlen;
        int i, j, p;
        *a_len = *ret_len = 0;
        for (i = 0; i < L->len; i++)
        {
                p = 0;
                a[p++] = L->element[i];
                for (j = i + 1; j < L->len; j++)
                {
                        if (L->element[j] <= L->element[j-1])
                                break;
                        a[p++] = L->element[j];
                }
                *a_len = p;
                /*
                printf("p: %d\n", p);
                printf("1a_len: %d\n", *a_len);
                printf("1ret_len: %d\n", *ret_len);
                */
                if (*a_len > *ret_len) {
                        fuzhi(ret, a, ret_len, a_len);
                        // printf("ret_len: %d\n", *ret_len);
                }
        }
        return ret;
}


void Initialize(List list)
{
        for (int i = 0; i < list->len; i++) {
                list->element[i] = i;
        }
}

void Initialize2(List list)
{
        list->element[0] = 233;
        /*
        list->element[1] = 9;
        list->element[2] = 2;
        list->element[3] = 5;
        list->element[4] = 7;
        list->element[5] = 3;
        list->element[6] = 4;
        list->element[7] = 6;
        list->element[8] = 8;
        list->element[9] = 0;
        list->element[10] = 11;
        list->element[11] = 15;
        list->element[12] = 17;
        list->element[13] = 17;
        list->element[14] = 10;
        */
}

void Initialize3(List list)
{
        list->element[0] = 9;
        list->element[1] = 8;
        list->element[2] = 7;
        list->element[3] = 6;
        list->element[4] = 5;
        list->element[5] = 4;
        list->element[6] = 3;
        list->element[7] = 2;
        list->element[8] = 1;
}

int main()
{
        int m;
        scanf("%d", &m);
        List list = CreateNewList(m);
        // Initialize(list);
        // Initialize2(list);
        Initialize3(list);
        print_list(list);
        // int *b = (int *)calloc(list->len, sizeof(int));
        // print_arr(b, list->len);
        int *b;
        b = FindMostSonList(list);
        print_arr(b, list->len);
        return 0;
}
